package com.kgo.eidtor.controller;

import com.kgo.eidtor.entity.StandardBean;
import com.kgo.eidtor.service.StandardService;
import com.kgo.eidtor.util.ResultUtil;
import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;

/**
 * @author keepgoon
 * @Description: TODO
 * @date 2019/1/3114:05
 */
@RestController
@CrossOrigin
public class StandardController {
    @Resource
    private StandardService standardService;
    @RequestMapping(value = "/standard" ,method = RequestMethod.POST,produces="text/plain;charset=UTF-8")
    public String addStandard(StandardBean standard){
        int rowCount = standardService.addStandard(standard);
        return ResultUtil.add(rowCount);
    }
    @RequestMapping(value = "/standards" ,method = RequestMethod.GET,produces="text/plain;charset=UTF-8")
    public String getStandards(StandardBean standard){
        return standardService.getStandards(standard);
    }
    @RequestMapping(value = "/standard" ,method = RequestMethod.GET,produces="text/plain;charset=UTF-8")
    public String getStandard(String id){
        return standardService.getStandardById(id);
    }
    @RequestMapping(value = "/detele/standard" ,method = RequestMethod.GET,produces="text/plain;charset=UTF-8")
    public String deteleStandard(String id){
        return ResultUtil.delete(standardService.deleteStandardById(id));
    }
    @RequestMapping(value = "/update/standard" ,method = RequestMethod.POST,produces="text/plain;charset=UTF-8")
    public String updateStandard(StandardBean standard){
        return ResultUtil.update(standardService.updateStandardById(standard));
    }
}
